inspector: Don't hardcode builtin themes
authorBenjamin Otte <otte@redhat.com>
Thu, 4 Feb 2016 12:34:34 +0000 (13:34 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 4 Feb 2016 12:35:21 +0000 (13:35 +0100)
Insteead, enumerate the resources that are available. Fixes windows
themes not being listed in the inspector.

gtk/inspector/visual.c

index 1f969cd098839a11c52ee00725209168415e81c7..ff2467b795be41b3e09950b80ff4d3ec2b287c90 100644 (file)
@@ -242,14 +242,19 @@ init_theme (GtkInspectorVisual *vis)
   GHashTable *t;
   GHashTableIter iter;
   gchar *theme, *path;
+  gchar **builtin_themes;
   GList *list, *l;
+  guint i;
 
   t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
   /* Builtin themes */
-  g_hash_table_add (t, g_strdup ("Adwaita"));
-  g_hash_table_add (t, g_strdup ("HighContrast"));
-  g_hash_table_add (t, g_strdup ("HighContrastInverse"));
-  g_hash_table_add (t, g_strdup ("Raleigh"));
+  builtin_themes = g_resources_enumerate_children ("/org/gtk/libgtk/theme", 0, NULL);
+  for (i = 0; builtin_themes[i] != NULL; i++)
+    {
+      if (g_str_has_suffix (builtin_themes[i], "/"))
+        g_hash_table_add (t, g_strndup (builtin_themes[i], strlen (builtin_themes[i]) - 1));
+    }
+  g_strfreev (builtin_themes);
 
   path = _gtk_css_provider_get_theme_dir ();
   fill_gtk (path, t);